package com.code.day19;

import java.util.HashMap;
import java.util.Scanner;

public class Demo06MapTrain {
    public static void main(String[] args) {
        HashMap<String,Integer> map = new HashMap<>();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个字符串:");
        String str = scanner.nextLine();
        char[] chars = str.toCharArray();
        for (char aChar : chars) {
            String key = aChar+"";
            if(!map.containsKey( key)){
                map.put(key,1);
            }else{
                Integer value = map.get(key);
                value++;
                map.put(key,value);
            }
        }
        for (String key : map.keySet()) {
            Integer value = map.get(key);
            System.out.println(key + "=" + value);
        }
    }
}
